package com.wsm.common.business.impl;

import com.wsm.common.business.VisitBusiness;
import com.wsm.common.domain.VisitDO;
import com.wsm.common.service.VisitService;
import com.wsm.common.utils.PageUtils;
import com.wsm.common.utils.Query;
import com.wsm.common.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 访客记录表
 *
 * @author wangshimin
 * @email wangshiminhome@foxmail.com
 * @date 2020-02-17 12:07:19
 * @description : 访客记录表
 */
@Service
public class VisitBusinessImpl implements VisitBusiness {
	@Autowired
	private VisitService visitService;

	@Override
	public VisitDO get(Long id) {
		return visitService.getById(id);
	}

	@Override
	public Result<PageUtils> list(Map<String, Object> params) {
		//查询列表数据
		Query query = new Query(params);
		List<VisitDO> visitList = visitService.list(query);
		int total = visitService.count(query);
		PageUtils pageUtils = new PageUtils(visitList, total);
		return Result.success(pageUtils);
	}

	@Override
	public Result save(VisitDO visit) {
		if (visitService.orSave(visit) > 0) {
			return Result.success();
		}
		return Result.error();
	}

	@Override
	public Result update(VisitDO visit) {
		visitService.update(visit);
		return Result.success();
	}

	@Override
	public Result remove(Long id) {
		if (visitService.remove(id) > 0) {
			return Result.success();
		}
		return Result.error();
	}

	@Override
	public Result batchRemove(Long[] ids) {
		visitService.batchRemove(ids);
		return Result.success();
	}


}
